import 'dart:async';
import 'dart:io';

import 'package:image_picker/image_picker.dart';
import 'package:flutter/material.dart';



class TakePhoto extends StatefulWidget {
  @override
  _TakePhotoState createState() => new _TakePhotoState();
}

class _TakePhotoState extends State<TakePhoto> {
  List<File> _normalDatas = [];
  File _image;
  var _temp = <Widget>[];
  Future getImage() async {
    var image = await ImagePicker.pickImage(source: ImageSource.camera);

    setState(() {
      _image = image;
      _normalDatas.add(image);
      _temp.add(new Padding(
        padding: const EdgeInsets.all(8.0),
        child: new SizedBox(
          height: 80.0,
          width: 80.0,
          child: Image.file(image),
        ),
      ));
    });
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text('Image Picker Example'),
      ),
      body: _image == null
          ? new Text('No image selected.')
          : new Row(children:_temp),
      floatingActionButton: new FloatingActionButton(
        onPressed: getImage,
        tooltip: 'Pick Image',
        child: new Icon(Icons.add_a_photo),
      ),
    );
  }
}